package com.company;

import java.util.HashMap;
import java.util.Map;

/**
 * HashMap key value都是可以为null的
 * get(key) != null
 * containKey(key)
 * 不相等
 * @date : 2023-06-29 上午10:09
 */

public class P060_HashMapKeyValueNull {

    public static void main(String[] args) {
        // keyNull();
        // valueNull();
        keyValueNull();
    }

    private static void keyNull() {
        Map<Object, Object> map = new HashMap<>();
        map.put("123", "123");
        System.out.println(map.containsKey(null));
        System.out.println(map.get(null));
        map.put(null, "123");
        System.out.println(map.get(null));
        System.out.println(map.containsKey(null));
    }

    private static void valueNull() {
        Map<Object, Object> map = new HashMap<>();
        map.put("123", null);
        System.out.println(map.containsKey("123"));
        System.out.println(map.get("123"));
    }

    private static void keyValueNull() {
        Map<Object, Object> map = new HashMap<>();
        map.put("123", "123");
        System.out.println(map.containsKey(null));
        System.out.println(map.get(null));
        map.put(null, null);
        System.out.println(map.containsKey(null));
        System.out.println(map.get(null));
    }
}
